package com.whfc.ms.api.base.controller;

import com.whfc.base.service.WarnConfigService;
import com.whfc.common.result.Result;
import com.whfc.common.result.ResultUtil;
import com.whfc.common.util.SessionAttr;
import com.whfc.fuum.entity.SysUser;
import org.apache.dubbo.config.annotation.DubboReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

/**
 * @author sun_guodong
 * @description 报警配置
 * @date 2020-12-18
 */
@RestController
@RequestMapping("/ms/api/warnConfig")
public class AppWarnConfigController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @DubboReference(interfaceClass = WarnConfigService.class, version = "1.0.0")
    private WarnConfigService warnConfigService;

    @PostMapping("/refresh")
    public Result refresh(@SessionAttribute(SessionAttr.MS_USER) SysUser user,
                          @RequestParam("deptId") Integer deptId,
                          @RequestParam("warnModuleType") Integer warnModuleType,
                          @RequestParam("type") Integer type) {
        logger.info("刷新报警配置缓存,loginer:{},deptId:{},warnModuleType:{},type:{}", user.getUsername(), deptId, warnModuleType, type);
        warnConfigService.refreshWarnConfig(deptId, warnModuleType, type);
        return ResultUtil.success();
    }


}
